<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - is_same_object.cpp</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2010  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font>
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='tester.h.html'>tester.h</a>"
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>dlib<font color='#5555FF'>/</font>svm.h<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>vector<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>sstream<font color='#5555FF'>&gt;</font>

<font color='#0000FF'>namespace</font>  
<b>{</b>
    <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> test;
    <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> dlib;
    <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> std;
    dlib::logger <b><a name='dlog'></a>dlog</b><font face='Lucida Console'>(</font>"<font color='#CC0000'>test.is_same_object</font>"<font face='Lucida Console'>)</font>;

    <b><a name='DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST'></a>DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST</b><font face='Lucida Console'>(</font>has_booya_template, <font color='#0000FF'><u>void</u></font>, <font color='#0000FF'>template</font> booya<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>int</u></font><font color='#5555FF'>&gt;</font>, <font face='Lucida Console'>(</font>std::string<font face='Lucida Console'>)</font><font color='#0000FF'>const</font><font face='Lucida Console'>)</font>
    <b><a name='DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST'></a>DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST</b><font face='Lucida Console'>(</font>has_booya2_template, <font color='#0000FF'><u>void</u></font>, <font color='#0000FF'>template</font> booya2<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>int</u></font><font color='#5555FF'>&gt;</font>, <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font><font color='#0000FF'>const</font><font face='Lucida Console'>)</font>
    <b><a name='DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST'></a>DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST</b><font face='Lucida Console'>(</font>has_funct_int, <font color='#0000FF'><u>void</u></font>, funct, <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
    <b><a name='DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST'></a>DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST</b><font face='Lucida Console'>(</font>has_funct_double, <font color='#0000FF'><u>void</u></font>, funct, <font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
    <b><a name='DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST'></a>DLIB_MAKE_HAS_MEMBER_FUNCTION_TEST</b><font face='Lucida Console'>(</font>has_funct_f, <font color='#0000FF'><u>float</u></font>, funct_f, <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>

    <font color='#0000FF'>class</font> <b><a name='htest'></a>htest</b>
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='booya'></a>booya</b><font face='Lucida Console'>(</font>std::string<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b><b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='booya2'></a>booya2</b><font face='Lucida Console'>(</font>EXP<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b><b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='funct'></a>funct</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font> <b>{</b><b>}</b>
    <b>}</b>;

    <font color='#0000FF'>class</font> <b><a name='htest2'></a>htest2</b>
    <b>{</b>
    <font color='#0000FF'>public</font>:

        <font color='#0000FF'><u>void</u></font> <b><a name='funct'></a>funct</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font> <b>{</b><b>}</b>

        <font color='#0000FF'><u>float</u></font> <b><a name='funct_f'></a>funct_f</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>0</font>;<b>}</b>
    <b>}</b>;

    <font color='#0000FF'><u>void</u></font> <b><a name='test_metaprog'></a>test_metaprog</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>has_booya2_template<font color='#5555FF'>&lt;</font>htest<font color='#5555FF'>&gt;</font>::value  <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>has_booya2_template<font color='#5555FF'>&lt;</font>htest2<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;

<font color='#0000FF'>#if</font> _MSC_VER <font color='#5555FF'>&gt;</font> <font color='#979000'>1600</font> <font color='#009900'>// there is a bug in visual studio 2010 and older that prevents this test from working
</font>        DLIB_TEST<font face='Lucida Console'>(</font>has_booya_template<font color='#5555FF'>&lt;</font>htest<font color='#5555FF'>&gt;</font>::value  <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'>#endif</font>

        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>has_booya_template<font color='#5555FF'>&lt;</font>htest2<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>has_funct_int<font color='#5555FF'>&lt;</font>htest<font color='#5555FF'>&gt;</font>::value  <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>has_funct_int<font color='#5555FF'>&lt;</font>htest2<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>has_funct_double<font color='#5555FF'>&lt;</font>htest<font color='#5555FF'>&gt;</font>::value  <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>has_funct_double<font color='#5555FF'>&lt;</font>htest2<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>has_funct_f<font color='#5555FF'>&lt;</font>htest<font color='#5555FF'>&gt;</font>::value  <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font>has_funct_f<font color='#5555FF'>&lt;</font>htest2<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>class</font> <b><a name='is_same_object_tester'></a>is_same_object_tester</b> : <font color='#0000FF'>public</font> tester
    <b>{</b>
        <font color='#009900'>/*!
            WHAT THIS OBJECT REPRESENTS
                This object represents a unit test.  When it is constructed
                it adds itself into the testing framework.
        !*/</font>
    <font color='#0000FF'>public</font>:
        <b><a name='is_same_object_tester'></a>is_same_object_tester</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> :
            tester <font face='Lucida Console'>(</font>
                "<font color='#CC0000'>test_is_same_object</font>",       <font color='#009900'>// the command line argument name for this test
</font>                "<font color='#CC0000'>Run tests on the is_same_object function.</font>", <font color='#009900'>// the command line argument description
</font>                <font color='#979000'>0</font>                     <font color='#009900'>// the number of command line arguments for this test
</font>            <font face='Lucida Console'>)</font>
        <b>{</b>
        <b>}</b>

        <font color='#0000FF'>struct</font> <b><a name='base'></a>base</b> <b>{</b><b>}</b>;
        <font color='#0000FF'>struct</font> <b><a name='derived'></a>derived</b> : <font color='#0000FF'>public</font> base <b>{</b><b>}</b>;

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'><u>bool</u></font> truth<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='go'></a>go</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> base<font color='#5555FF'>&amp;</font> a, <font color='#0000FF'>const</font> base<font color='#5555FF'>&amp;</font> b<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>a,b<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> truth<font face='Lucida Console'>)</font> ;
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>b,a<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> truth<font face='Lucida Console'>)</font> ;
        <b>}</b>


        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'><u>bool</u></font> truth<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='go2'></a>go2</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> base<font color='#5555FF'>&amp;</font> a, <font color='#0000FF'>const</font> derived<font color='#5555FF'>&amp;</font> b<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>a,b<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> truth<font face='Lucida Console'>)</font> ;
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>b,a<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> truth<font face='Lucida Console'>)</font> ;
        <b>}</b>


        <font color='#0000FF'><u>void</u></font> <b><a name='perform_test'></a>perform_test</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'><u>int</u></font> a, b;
            <font color='#0000FF'><u>double</u></font> d;
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>a,a<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font> ;
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>a,b<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font> ;
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>d,b<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font> ;
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>d,d<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font> ;

            base sb;
            derived sd, sd2;

            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>sb,sd<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font> ;
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>is_same_object</font><font face='Lucida Console'>(</font>sd,sb<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font> ;

            go<font color='#5555FF'>&lt;</font><font color='#979000'>true</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>sd, sd<font face='Lucida Console'>)</font>;
            go<font color='#5555FF'>&lt;</font><font color='#979000'>false</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>sd, sd2<font face='Lucida Console'>)</font>;
            go<font color='#5555FF'>&lt;</font><font color='#979000'>true</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>sb, sb<font face='Lucida Console'>)</font>;
            go<font color='#5555FF'>&lt;</font><font color='#979000'>false</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>sd, sb<font face='Lucida Console'>)</font>;

            go2<font color='#5555FF'>&lt;</font><font color='#979000'>true</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>sd, sd<font face='Lucida Console'>)</font>;
            go2<font color='#5555FF'>&lt;</font><font color='#979000'>false</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>sd2, sd<font face='Lucida Console'>)</font>;
            go2<font color='#5555FF'>&lt;</font><font color='#979000'>false</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>sd, sd2<font face='Lucida Console'>)</font>;
            go2<font color='#5555FF'>&lt;</font><font color='#979000'>false</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>sb, sd<font face='Lucida Console'>)</font>;

            <font color='#BB00BB'>test_metaprog</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>;

    <font color='#009900'>// Create an instance of this object.  Doing this causes this test
</font>    <font color='#009900'>// to be automatically inserted into the testing framework whenever this cpp file
</font>    <font color='#009900'>// is linked into the project.  Note that since we are inside an unnamed-namespace 
</font>    <font color='#009900'>// we won't get any linker errors about the symbol a being defined multiple times. 
</font>    is_same_object_tester a;

<b>}</b>




</pre></body></html>